package com.nowcoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class PrimePartner {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int[] arr = new int[n];
            for (int i = 0; i < n; i++) {
                arr[i] = scanner.nextInt();
            }
            // 初始化素数伴侣下标均为-1
            Arrays.fill(primePartner, -1);
            System.out.println(solver(arr));
        }
    }

    private static final int MAX_LEN = 100;

    /**
     * 由于数n的个数[1,100], 所以互素的对数最大为50对
     */
    private static int[] primePartner = new int[MAX_LEN];

    private static boolean[] used = new boolean[MAX_LEN];

    /**
     * 匈牙利算法，解决二分图最大匹配问题; 将整数分成两个部分，奇数和偶数各一组；因为
     * 奇数和奇数的和是偶数，肯定不会是素数；偶数和偶数的和是偶数，肯定不会是素数。
     *
     * @param arr
     * @return
     */
    public static int solver(int[] arr) {
        int res = 0;
        // 将数组中的元素，放到两个集合中，集合之内的任意两个元素之和不是素数，
        // 集合之间的两个元素之和是素数
        List<Integer> evenList = new ArrayList<>();
        List<Integer> oddList = new ArrayList<>();
        int len = arr.length;
        for (int i = 0; i < len; i++) {
            if ((arr[i] % 2) == 1) {
                oddList.add(arr[i]);
            } else {
                evenList.add(arr[i]);
            }
        }
        int evenLen = evenList.size();
        for (int i = 0; i < evenLen; i++) {
            Arrays.fill(used, false);
            if (find(evenList.get(i), oddList)) {
                res++;
            }
        }
        return res;
    }

    private static boolean find(int even, List<Integer> oddList) {
        int oddLen = oddList.size();
        for (int i = 0; i < oddLen; i++) {
            if (isPrime(even + oddList.get(i)) && !used[i]) {
                used[i] = true;
                if (primePartner[i] == -1 || find(primePartner[i], oddList)) {
                    primePartner[i] = even;
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 判断一个数是否是素数
     *
     * @param n
     * @return
     */
    private static boolean isPrime(int n) {
        if (n == 1) {
            return false;
        }
        for (int i = 2; i * i <= n; i++) {
            if (n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
